package com.cw.jeeyt.service.converter.git;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.git.GitSendEmailRecordBo;
import com.cw.jeeyt.dao.model.git.GitSendEmailRecordDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 邮件发送通知记录转换类
 *
 * @author chenw
 * @date 2019-02-25 01:04:34
 */
public class GitSendEmailRecordConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static GitSendEmailRecordBo do2Bo(GitSendEmailRecordDo model) {
        if (model == null) {
            return null;
        }
        GitSendEmailRecordBo bo = new GitSendEmailRecordBo();
        bo.setRecordId(model.getRecordId());
        bo.setSendUserId(model.getSendUserId());
        bo.setReceiveUserIds(model.getReceiveUserIds());
        bo.setSendContent(model.getSendContent());
        bo.setSendTime(model.getSendTime());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static GitSendEmailRecordDo bo2Do(GitSendEmailRecordBo bo) {
        if (bo == null) {
            return null;
        }
        GitSendEmailRecordDo model = new GitSendEmailRecordDo();
        model.setRecordId(bo.getRecordId());
        model.setSendUserId(bo.getSendUserId());
        model.setReceiveUserIds(bo.getReceiveUserIds());
        model.setSendContent(bo.getSendContent());
        model.setSendTime(bo.getSendTime());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<GitSendEmailRecordBo> doList2BoList(List<GitSendEmailRecordDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), GitSendEmailRecordConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<GitSendEmailRecordDo> boList2DoList(List<GitSendEmailRecordBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), GitSendEmailRecordConverter::bo2Do));
    }
}